package com.qdlc.p2p.biz.service.borrow.impl;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.qdlc.p2p.biz.service.*;
import com.qdlc.p2p.common.constant.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.qd.p2p.adapter.Response;
import com.qd.p2p.adapter.enums.ResponseStatus;
import com.qd.p2p.sina.pay.enums.IdentityType;
import com.qdlc.p2p.biz.executer.impl.NewActivityAwardExecutor;
import com.qdlc.p2p.biz.processor.event.BorrowFullVerifyPayNoticeEvent;
import com.qdlc.p2p.biz.processor.event.TppDispatchValueEvent;
import com.qdlc.p2p.biz.util.NoticeTemplateSender;
import com.qdlc.p2p.common.core.ReturnResult;
import com.qdlc.p2p.common.core.queue.QueueHandlers;
import com.qdlc.p2p.common.enums.EnumActicityPlanNid;
import com.qdlc.p2p.common.util.BigDecimalUtil;
import com.qdlc.p2p.common.util.CollectionUtils;
import com.qdlc.p2p.common.util.DataUtils;
import com.qdlc.p2p.common.util.DateUtil;
import com.qdlc.p2p.common.util.MailUtil;
import com.qdlc.p2p.common.util.OrderNoUtil;
import com.qdlc.p2p.dal.common.SystemConfigHelper;
import com.qdlc.p2p.dal.dao.BorrowCollectionDao;
import com.qdlc.p2p.dal.dao.BorrowRepaymentDao;
import com.qdlc.p2p.dal.dao.BorrowTenderDao;
import com.qdlc.p2p.dal.dao.TppDao;
import com.qdlc.p2p.dal.dao.TppSinaSplitDao;
import com.qdlc.p2p.dal.dao.UserDao;
import com.qdlc.p2p.dal.dto.Borrow;
import com.qdlc.p2p.dal.dto.BorrowRepayment;
import com.qdlc.p2p.dal.dto.BorrowTender;
import com.qdlc.p2p.dal.dto.Tpp;
import com.qdlc.p2p.dal.dto.TppSinaSplit;
import com.qdlc.p2p.dal.dto.TppTradeLog;
import com.qdlc.p2p.dal.dto.User;
import com.qdlc.p2p.dal.model.BorrowModel;
import com.qdlc.p2p.dal.model.TppModel;
import com.qdlc.p2p.dal.model.TppTradeLogModel;
import com.qdlc.p2p.dal.model.interest.InterestCalculator;
import com.qdlc.p2p.dal.util.SystemConfigs;
import com.qdlc.p2p.dal.util.UserUtils;

/**
 * 满标复审 代付服务类
 *
 * @author Kaiju Zhao
 * @date 2016-03-09
 * @version 1.1.0.0
 */
@Service("borrowFullVerifyPayService")
public class BorrowFullVerifyPayServiceImpl extends AbstractPayService  {

	private final static String BUSINESS_NAME = "满标复审代付-";

	// 借款标Model
	private ThreadLocal<BorrowModel> borrowModelLocal = new ThreadLocal<BorrowModel>();

	@Resource
	private BorrowTenderDao borrowTenderDao;

	@Resource
	private BorrowCollectionDao borrowCollectionDao;

	@Resource
	private InterestService interestService;

	@Resource
	private BorrowCollectionService borrowCollectionService;

	@Resource
	private BorrowRepaymentDao borrowRepaymentDao;

	@Resource
	private BorrowService borrowService;

	@Resource
	private RateInterestService rateInterestService;

	@Resource
	private BorrowTenderService borrowTenderService;

	@Resource
	private TppSinaSplitDao tppSinaSplitDao;

	@Resource
	private TppDao tppDao;

	@Resource
	private UserDao userDao;
	@Resource
	private CashAwardRuleService cashAwardRuleService;

	@Resource
	@Qualifier("bfRPCRequestService")
	private RPCRequestService<Response, TppTradeLog> rpcRequestService;

	@Override
	public String getCallBackUrl() {
		return WEB_URL.concat(NotifyUrl.BORROW_LOAN_NOTIFY_PAY_URL).concat(".html");
	}

	@Override
	public String getBusinessName() {
		return BUSINESS_NAME;
	}

	@Override
	public void analyzePars(Object... pars) {
		if (null == pars
				|| 1 !=  pars.length) {
			throw new IllegalArgumentException("参数个数不正确!");
		}

		if (null == pars[0]) {
			throw new IllegalArgumentException("参数不能为null!");
		}

		boolean isBorrowModel = pars[0] instanceof BorrowModel;
		if (!isBorrowModel) {
			throw new IllegalArgumentException("参数类型不正确!");
		}

		if (isBorrowModel) {
			borrowModelLocal.set((BorrowModel) pars[0]);
		}
	}

	@Override
	public TppTradeLog createOrder(Object... pars) {
		analyzePars(pars);

		// 可变参数
		TppTradeLog tppTradeLog = getTppTradeLog();
		// 固定参数
		tppTradeLog.setTppUserCustId(String.valueOf(GeneralAccountType.PLATFORM)); // 付款方
		tppTradeLog.setBorrowRepaymentId(GeneralAccountType.INVESTOR);
		tppTradeLog.setIdentityType(IdentityType.UID.name());
		tppTradeLog.setServiceType(Summary.LOAN.getSummaryType());
		tppTradeLog.setAddTime(DateUtil.getNow()); // 交易时间
		return tppTradeLog;
	}

	@Override
	public ReturnResult requestOrder(TppTradeLog tppTradeLog) {
		Response response = null;
		if (!isSuspend(tppTradeLog.getTradeType())) {
			response = rpcRequestService.fullBorrowLoadRequest(tppTradeLog);
		}

		// 未知状态通知 交由消息队列处理
		if (null == response || ResponseStatus.UN_KNOW == response.getStatus()) {
			notice(tppTradeLog, TradeStatus.TRADE_STATUS_UN_KNOW);
			return new ReturnResult(true, "系统处理中!");
		}

		ResponseStatus status = response.getStatus();

		if (ResponseStatus.SUCCESS == status) {
			tppTradeLog.setRemark(getBusinessName().concat("提交成功"));
			tppTradeService.update(tppTradeLog);

			// 成功通知
			notice(tppTradeLog, TradeStatus.TRADE_STATUS_FINISHED);
			requestOrderSuccess(tppTradeLog); // 请求成功处理
		} else if (ResponseStatus.FAILURE == status) {
			String message = response == null ? "RPC调用失败" : MessageFormat.format("{0}代收失败!responseCode:{1} responseMsg:{2}",
					getBusinessName(), response.getResponseCode(), response.getResponseMsg());
			String responseMessage = response == null ? "RPC调用失败" : response.getResponseMsg();
			logger.info(message);

			// 置为废单
			tppTradeLog.setTradeStatus(TradeStatus.TRADE_STATUS_INVALID.getStatus());
			tppTradeLog.setRemark(getBusinessName().concat("提交失败-" + responseMessage));
			tppTradeService.update(tppTradeLog);

			requestOrderFail(tppTradeLog); // 请求失败处理
			return new ReturnResult(true, message);
		}
		return ReturnResult.SUCCESS;
	}

	@Override
	public TppTradeLog getTppTradeLog() {
		BorrowModel borrowModel = borrowModelLocal.get();
		// 获取已处理的投标记录
		long borrowId = borrowModel.getId();

		// 投标交易额合并
		List<BorrowTender> tenderList = borrowTenderDao.find(borrowId, BorrowTenderStatus.PROCESSED);
		double transTotalAmount = 0;
		for (BorrowTender tender : tenderList) {
			// 投标总交易额
			transTotalAmount = BigDecimalUtil.add(transTotalAmount, tender.getAccount());
		}

		// 生成订单号
		String orderNo = OrderNoUtil.getInstance().getSerialNumber();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("borrowId", borrowModel.getId());

		String tppUserCustId = UserUtils.getUserTppCustId(borrowModel.getUser().getUserId());
		String splitList = "";
		if (transTotalAmount > 0) {
			// 计算借款管理费收取比例
			double manageFeeRate = borrowService.getBorrowManageFeeRate(borrowModel);
			// 借款入账管理费 需要借款人交给平台
			double manageFeeTotal = BigDecimalUtil.round(BigDecimalUtil.mul(transTotalAmount, manageFeeRate), 2);
			if (manageFeeTotal > 0) {
				String memberEmail = SystemConfigHelper.getValue(SystemConfigHelper.Nid.MEMBER_EMAIL);
				String accountType = SystemConfigHelper.getValue(SystemConfigHelper.Nid.ACCOUNT_TYPE);
				map.put("manageSplitUser", memberEmail);
				map.put("manageSplitRemark", "借款入账管理费");
				TppSinaSplit manageSplit = new TppSinaSplit(orderNo, tppUserCustId,
						SinaConstant.IDENTITY_TYPE_UID, accountType, memberEmail,
						SinaConstant.IDENTITY_TYPE_EMAIL, SinaConstant.ACCOUNT_TYPE_BASIC, manageFeeTotal + "",
						"借款入账管理费");
				map.put("manageSplit", manageSplit);
				map.put("manageFee", manageFeeTotal);
				List<TppSinaSplit> tppSinaSplitList = new ArrayList<TppSinaSplit>();
				tppSinaSplitList.add(manageSplit);
				splitList = TppSinaSplit.getSplitList(tppSinaSplitList, memberEmail);
			}
		}

		TppTradeLog tppTradeLog = new TppTradeLog();
		tppTradeLog.setOrderNo(orderNo); // 订单号
		tppTradeLog.setToTppUserCustId(tppUserCustId); // 标所属用户标识
		tppTradeLog.setBorrowId(borrowModel.getId()); // 标ID
		tppTradeLog.setMoney(transTotalAmount); // 放款金额
		tppTradeLog.setSplitList(splitList); // 分账信息
		tppTradeLog.setMemo(JSON.toJSONString(map)); // 备注信息
		tppTradeLog.setAssociateOrderId(orderNo);  // 自个关联
		tppTradeLog.setId(GeneralAccountType.INVESTOR);
		tppTradeLog.setTradeType(TradeCode.C2007.toString());
		return tppTradeLog;
	}

	@Override
	public void tradeFinish(TppTradeLog tppTradeLog, String depositStatus, double tradeAmount) {
		super.tradeFinishForStatus(tppTradeLog, depositStatus, tradeAmount);

		// 满标复审通过,处理相应信息
		long borrowId = tppTradeLog.getBorrowId();
		Borrow borrow = borrowService.getBorrowById(borrowId);
		BorrowModel borrowModel = BorrowModel.instance(borrow);
		borrowModel.setStatus(BorrowStatus.STATUS_RECHECK_PASS);

		// 生成放款记录
		createCollections(borrowModel);

		// 满标复审通过后，处理borrow、repayment
		borrowAfterFullVerify(borrowModel);

		// 生成分账信息（如借款入账管理费）
		createTppSinaSplits(borrowModel, tppTradeLog);

		// 标状态更新为还款中
		borrowService.updateStatus(borrowId, BorrowStatus.STATUS_REPAYMENT_START, BorrowStatus.STATUS_RECHECK_PASS);

		borrow.setReviewTime(DateUtil.getNow());
		borrowService.update(borrow);

		// 给借款人发送通知
		User user = borrowModel.getUser();
		NoticeTemplateSender borrowUserNoticeSender = NoticeTemplateSender.newInstance(user, LogTplNid.BORROW_FULL_SUCC);
		borrowUserNoticeSender.addSendData("borrow", borrowModel);
		borrowUserNoticeSender.send();

		List<BorrowTender> tenderList = borrowTenderDao.find(borrowModel.getId(), BorrowTenderStatus.SUCCESS);
		Map<Long, BorrowTender>  tenderUserMap = new HashMap<Long, BorrowTender>();
		if (CollectionUtils.isNotNullOrEmpty(tenderList)) {
			for (BorrowTender tender : tenderList) {
				// 给投资人发送通知
				// 同一个投资人只发一条短信
				BorrowTender borrowTender;
				StringBuilder tenderDetails = new StringBuilder();
				long tenderUserId = tender.getUser().getUserId();
				if (tenderUserMap.containsKey(tenderUserId)) {
					borrowTender = tenderUserMap.get(tenderUserId);
					double account = BigDecimalUtil.add(borrowTender.getAccount(), tender.getAccount());
					int tenderCount = borrowTender.getStatus() + 1;
					// 复用status字段保存 投标次数
					borrowTender.setStatus(tenderCount);
					borrowTender.setAccount(account);
					// 复用addIp字段保存详细信息
					tenderDetails.append(borrowTender.getAddIp()).append("、").append(tender.getAccount());
				} else {
					borrowTender = new BorrowTender();
					BeanUtils.copyProperties(tender, borrowTender);
					// 复用status字段保存 投标次数
					borrowTender.setStatus(1);
					tenderDetails.append(tender.getAccount());
				}
				// 复用addIp字段保存详细信息
				borrowTender.setAddIp(tenderDetails.toString());
				tenderUserMap.put(tenderUserId, borrowTender);
			}
		}

		for (Map.Entry<Long, BorrowTender> entry : tenderUserMap.entrySet() ) {
			BorrowTender tender = entry.getValue();
			if (null != tender) {
				// 满审成功活动环节
				try {
					if (borrow.getBorrowTimeType() != BorrowTimeType.DAY && 
							borrow.getCategory() != BorrowCategory.EXPERIENCE ) {// 只针对月标和非体验标
						User tenderUser = tender.getUser();
						// 该标当前用户累计投资金额
						Map<String, Object> extMpas = new HashMap<String, Object>();
						extMpas.put("timeLimit", borrow.getTimeLimit());// 标期限
						extMpas.put("tenderMoneySum", tender.getAccount());// 投标金额（已累计）
						extMpas.put("borrowId", borrow.getId());// 标id
						NewActivityAwardExecutor.giveByTache(tenderUser, EnumActicityPlanNid.VERIFY_FULL_BORROW_SUCCESS.getValue(), extMpas);
					}
					//满标复审发放客户奖励 针对普通标发放客户奖励
					if(borrow.getCategory() == BorrowCategory.USUALLY &&  borrow.getType() == BorrowType.TYPE_OFFVOUCH && !borrow.isRecommend()){
						cashAwardRuleService.giveRebate(tender.getUser(),tender.getAccount());
					}

					//是否首次投标
					BorrowTender borrowTender = borrowTenderDao.getUserFirstTender(tender.getUser().getUserId());
					if (borrowTender.getId() == tender.getId()&&!tender.getBorrow().isRecommend()&&tender.getBorrow().getType()== BorrowType.TYPE_OFFVOUCH) {
						cashAwardRuleService.giveMoney(tender.getUser(), borrowTender.getMoney());
					}
				} catch (Exception e) {
					logger.info("满审成功活动环节发放有误，tenderUserId:"+tender.getUser().getUserId());
					e.printStackTrace();
				}
				
				// 发消息开始
				NoticeTemplateSender tenderUserNoticeSender = NoticeTemplateSender.newInstance(tender.getUser(), LogTplNid.INVEST_SUCC);
				tenderUserNoticeSender.addSendData("tenderMoney", tender.getAccount());
				// 详细信息
				tenderUserNoticeSender.addSendData("tenderDetails", tender.getAddIp());
				// 投标总次数
				tenderUserNoticeSender.addSendData("tenderCount", tender.getStatus());
				tenderUserNoticeSender.addSendData("borrow", borrowModel);
				tenderUserNoticeSender.send();
			}
		}
		if(borrow.getType()== BorrowType.TYPE_OFFVOUCH&&!borrow.isRecommend()&&borrow.getCategory()==1){
			cashAwardRuleService.giveAwards(borrow.getId());
		}
	}

	/**
	 * 满标复审通过后 生成代收记录
	 *
	 * @author Kaiju Zhao
	 * @param borrowModel 借款标
	 */
	private void createCollections(BorrowModel borrowModel) {
		long borrowId = borrowModel.getId();
		User user = borrowModel.getUser();
		long toUserId = user.getUserId();

		// 已处理的投标记录
		List<BorrowTender> tenderList = borrowTenderDao.find(borrowId, BorrowTenderStatus.PROCESSED);
		for (BorrowTender tender : tenderList) {
			User tenderUser = tender.getUser();
			double account = tender.getAccount(); // 投标金额

			InterestCalculator calculator = interestService.interestCalculator(borrowModel, account);
			tender = borrowTenderService.tenderSuccess(tender, calculator);

			// 投标奖励值 暂时去掉奖励
			double award = 0;
			//double award = calculateAward(borrowModel, account);
			// 生成代还记录
			borrowCollectionService.createCollectionList(tender, calculator, award);

			long userId = tenderUser.getUserId();

			// 扣除冻结投标金额，生成待收本金
			Global.setTransfer(LogTplNid.LOG_TPL_KEY, LogTplNid.INVEST);
			Global.setTransfer("web_url", WEB_URL);
			Global.setTransfer("borrow", borrowModel);
			Global.setTransfer("collectionCapital", account);
			accountService.deductNoUseMoneyAndAddCollection(userId, toUserId, account);

			// 生成待收利息
			double interest = tender.getInterest();
			Global.setTransfer(LogTplNid.LOG_TPL_KEY, LogTplNid.WAIT_INTEREST);
			Global.setTransfer("web_url", WEB_URL);
			Global.setTransfer("money", interest);
			accountService.addCollectionAndTotal(userId, toUserId, interest);

			// 进行投标奖励
			if (award > 0) {
				Global.setTransfer(LogTplNid.LOG_TPL_KEY, LogTplNid.AWARD_ADD);
				Global.setTransfer("web_url", WEB_URL);
				Global.setTransfer("award", award);
				Global.setTransfer("user", tenderUser);
				accountService.addUseMoneyAndTotal(userId, toUserId, award);
			}

			// 附加增值功能处理
			additionalTenderAfterFullVerify(tender);
		}
	}

	/**
	 * 附加增值功能处理
	 *
	 * @author Kaiju Zhao
	 * @param tender
	 */
	private void additionalTenderAfterFullVerify(BorrowTender tender) {
		// 处理加息券相关业务，放款时，计算每一期利息的差值
		rateInterestService.borrowSuccessDoRate(tender.getId(), LogTplNid.RATE_CREATE_INTEREST);
	}

	/**
	 * 满标复审通过后，处理borrow、repayment
	 *
	 * @author Kaiju Zhao
	 * @param borrowModel
	 */
	private void borrowAfterFullVerify(BorrowModel borrowModel) {
		// 借款人资金入账
		double account = borrowModel.getAccount();
		Global.setTransfer(LogTplNid.LOG_TPL_KEY, LogTplNid.BORROW_SUCCESS);
		Global.setTransfer("web_url", WEB_URL);
		Global.setTransfer("money", account);
		Global.setTransfer("borrow", borrowModel);
		User user = borrowModel.getUser();
		accountService.addUseMoneyAndTotal(user.getUserId(), GeneralAccountType.INVESTOR, account);

		// 生成还款计划
		List<BorrowRepayment> borrowRepaymentList = new ArrayList<BorrowRepayment>();
		int time;
		if (BorrowStyle.STYLE_ONETIME_REPAYMENT == borrowModel.getStyle()) {
			time = 1;
		} else {
			time = borrowModel.getTimeLimit();
		}
		long id = borrowModel.getId();
		for (int i = 0; i < time; i++) {
			BorrowRepayment repayment = new BorrowRepayment();
			// 获取投标的待收本金和待收利息
			Object[] capitalAndInterest = borrowCollectionDao
					.getCapitalAndInterestByBorrowAndPeriod(id, i);
			double capital = (Double) (capitalAndInterest[0]);
			double interest = (Double) (capitalAndInterest[1]);

			repayment.setUser(user);
			repayment.setBorrow(borrowModel);
			repayment.setPeriod(i);

			Date flowRepayTime = borrowService
					.getFlowRepayTime(borrowModel, repayment.getPeriod());
			repayment.setRepaymentTime(flowRepayTime);
			double repaymentAccount = BigDecimalUtil.add(capital, interest);
			repayment.setRepaymentAccount(repaymentAccount);
			repayment.setInterest(interest);
			repayment.setWebStatus(BorrowRepayment.WEB_STATUS_NORMAL);
			repayment.setCapital(capital);
			repayment.setAddTime(DateUtil.getNow());
			repayment.setAddIp(Global.getIP());
			borrowRepaymentList.add(repayment);
		}
		borrowRepaymentDao.save(borrowRepaymentList);
	}

	/**
	 * 生成分账信息（如借款入账管理费）
	 *
	 * @author Kaiju Zhao
	 * @param borrowModel 借款标
	 * @param tppTradeLog 交易记录日志
	 */
	private void createTppSinaSplits(BorrowModel borrowModel, TppTradeLog tppTradeLog) {
		JSONObject memoObj = JSON.parseObject(tppTradeLog.getMemo());
		if (null != memoObj) {
			// 借款入账管理费
			TppSinaSplit manageSplit = JSON.parseObject(memoObj.getString("manageSplit"), TppSinaSplit.class);
			if (null != manageSplit) {
				tppSinaSplitDao.save(manageSplit);

				double manageFee = DataUtils.toDouble(manageSplit.getAmount());
				// 借款入账管理费 需要借款人交给平台
				if (manageFee > 0) {
					// 平台交易方
					Global.setTransfer(LogTplNid.LOG_TPL_KEY, LogTplNid.BORROW_FEE);
					Global.setTransfer("deduct", borrowModel);
					Global.setTransfer("money", manageFee);
					accountService.deductUseMoneyAndTotal(borrowModel.getUser().getUserId(), SystemConfigs.ADMIN_ID, manageFee);
				}
			}
		}
	}

	@Override
	public void tradeSuccess(TppTradeLog tppTradeLog, String depositStatus) {
		super.tradeSuccessForStatus(tppTradeLog, depositStatus);
	}

	@Override
	public void tradeFail(TppTradeLog tppTradeLog, String depositStatus) {
		super.tradeFailForStatus(tppTradeLog, depositStatus);
		// 回调失败
		requestOrderFail(tppTradeLog);
	}

	@Override
	public void requestOrderSuccess(TppTradeLog tppTradeLog) {
		Borrow borrow = borrowService.getBorrowById(tppTradeLog.getBorrowId());
		borrowService.updateStatus(borrow.getId(), BorrowStatus.STATUS_RECHECK_PASS, BorrowStatus.STATUS_TRIAL_PASSED);

		borrow.setReviewTime(DateUtil.getNow());
		borrowService.update(borrow);
	}

	@Override
	public void requestOrderFail(TppTradeLog tppTradeLog) {
		Borrow borrow = borrowService.getBorrowById(tppTradeLog.getBorrowId());
		borrow.setStatus(BorrowStatus.STATUS_TRIAL_PASSED);
		borrow.setReviewTime(DateUtil.getNow());
		borrowService.update(borrow);

		// 保存调度任务信息
		Tpp tpp = new Tpp();
        tpp.setStatus(TppModel.STATUS_FAIL);
        tpp.setServiceType(TppModel.BORROWVERIFYFULLSUCCESS);
        tpp.setTppType(SinaConstant.TRADE_SERVICE_LOAN);
        tpp.setTppUserCustId(String.valueOf(GeneralAccountType.PLATFORM));// 付款方
        String toTppUserCustId = tppTradeLog.getToTppUserCustId();
        User toUser = userDao.findObjByProperty("tppUserCustId", toTppUserCustId);
        tpp.setToUser(toUser);// 收款方
        tpp.setToTppUserCustId(toTppUserCustId);
        tpp.setMoney(tppTradeLog.getMoney());
        tpp.setOrderId(tppTradeLog.getOrderNo());
        tpp.setOrderDate(DateUtil.dateStr7(tppTradeLog.getAddTime()));
        tpp.setTradeType(tppTradeLog.getTradeType());
        tpp.setRespDesc(tppTradeLog.getRemark());
        tpp.setAddTime(DateUtil.getNow());
        tppDao.save(tpp);

		// 调度任务交由队列处理(延时处理)
        if (tppTradeLog.getAutoDispatch() != TppTradeLogModel.IS_AUTO) {// 防止重复处理
        	TppModel tppModel = TppModel.instance(tpp);
        	TppDispatchValueEvent tppDispatchValueEvent = new TppDispatchValueEvent();
        	tppDispatchValueEvent.setTppModel(tppModel);
            QueueHandlers.put(tppDispatchValueEvent);
        }

		// 邮件通知(技术员用)
        String message = BUSINESS_NAME + "交易失败";
		MailUtil.sendMail(message, message + " ,交易记录(TppTradeLog)中的订单号orderNo: " + tppTradeLog.getOrderNo(), "");
	}

	/**
	 * 发送满标放款通知 交由队列来执行
	 */
	private void notice(TppTradeLog tppTradeLog, TradeStatus tradeStatus) {
		BorrowFullVerifyPayNoticeEvent noticeEvent = new BorrowFullVerifyPayNoticeEvent();
		noticeEvent.setClientIp(Global.getIP());
		noticeEvent.setTradeStatus(tradeStatus);
		noticeEvent.setTppTradeLog(tppTradeLog);
		noticeEvent.setOutOrderNo(tppTradeLog.getOrderNo());
		noticeEvent.setDepositAmount(tppTradeLog.getMoney());
		QueueHandlers.put(noticeEvent);
	}

}
